home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / COMMUNIC / TERMINAL / 1589.ZIP / TERMNRES.C < prev    next >
Text File  |  1989-04-13  |  20KB  |  587 lines

  1.  
  2. /*****************************************************************************
  3. **  The following functions are called from the TermWndProc() function.
  4. **
  5. *****************************************************************************/
  6. #include "windows.h"
  7. #include "term.h"
  8. #include "icu_user.h"
  9.  
  10. TermCreate( hWnd )
  11. HWND  hWnd;
  12. {
  13. int h, w;
  14. TEXTMETRIC tm;
  15.  
  16. hTermDC  = GetDC (hWnd);                          /* get display context  */
  17.  
  18. /* Add fonts to Windows resource.  Needed for IBM graphic characters */
  19. if ( !(ret = AddFontResource( (LPSTR) "FONTRES.FON" )) )
  20.    pmsg("Unable to add FONTRES fonts to WINDOWS.");
  21. else
  22.    SendMessage( -1, WM_FONTCHANGE, 0, 0L );
  23.  
  24. if ( !(ret = AddFontResource( (LPSTR) "IBM.FON" )) )
  25.    pmsg("Unable to add IBM fonts to WINDOWS.");
  26. else
  27.    SendMessage( -1, WM_FONTCHANGE, 0, 0L );
  28.  
  29. IBMfont = CreateFont( 14, 12,0,0,0,0,0,0,
  30.            OEM_CHARSET, OUT_DEFAULT_PRECIS,
  31.            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  32.            FIXED_PITCH|FF_DONTCARE, (LPSTR) "IBM" );
  33. if ( IBMfont == NULL ) {                         /* Unable to load font  */
  34.    pmsg("Unable to select IBM style font.");
  35.    IBMfont = GetStockObject( SYSTEM_FONT );
  36.    }
  37. SelectObject( hTermDC, IBMfont );
  38.  
  39. GetTextMetrics( hTermDC, (TEXTMETRIC FAR *)&tm); /* text size            */
  40. char_w = tm.tmAveCharWidth;                      /* char width           */
  41. char_h = tm.tmHeight + tm.tmExternalLeading;     /* char height          */
  42.  
  43. Capture      = FALSE;      /* Flags, etc, used in the capture routines */
  44. CaptureFD    = -1;         /*  "      "     "  "    "   "         "    */
  45. CaptureLine  =  1;         /*  "      "     "  "    "   "         "    */
  46. curs_pos.x   = char_w;     /* Current X Caret position                 */
  47. curs_pos.y   = 1;          /* Current Y Caret position                 */
  48. next_line    = 0;          /* Offset for the next line in the display  */
  49. next_char    = 0;          /* Offset for the next col. in the display  */
  50. GraphicsMode = FALSE;      /* Turn graphics mode off                   */
  51. CaretMode    = TRUE;       /* Turn the caret on                        */
  52. TermHasFocus = TRUE;       /* Set when TERMINAL has the focus          */
  53. PaintWindow  = TRUE;       /* Set after a scroll to prevent a repaint  */
  54. }
  55.  
  56.  
  57. TermCharInput(hWnd, ch, cRepeat)
  58. HWND hWnd;
  59. int ch;
  60. int cRepeat;
  61. {
  62. int i, ret;
  63.  
  64. while (cRepeat-- != 0) {
  65.    if ( ch < 0x20 ) {                  /* A CONTROL character, send at once */
  66.        if ( ch != CR && ch != LF )
  67.            fileput("Sending CONTROL character %XH", ch );
  68.        TransmitCommChar( nCID, ch );
  69.        }
  70.    else {
  71.        for (i=0,ret=-1;i<5,ret<0;i++)   /* Try to send character five times */
  72.            ret = WriteComm( nCID, (LPSTR)&ch, 1 );
  73.        if (ret<0) {                     /* ERROR xmting   */
  74.            fileput("Transmit Error #%d", ret );
  75.            DisplayCommError();
  76.            }
  77.        }
  78.    }
  79. }
  80.  
  81. TermClose(hWnd)
  82. HWND hWnd;
  83. {
  84.    char    szOkClose[CCHMAXSTRING], szClose[CCHMAXSTRING];
  85.  
  86.    LoadString(hInstTerm, IDSOKCLOSE, (LPSTR)szOkClose, CCHMAXSTRING);
  87.    LoadString(hInstTerm, IDSCLOSE,   (LPSTR)szClose  , CCHMAXSTRING);
  88.    MessageBeep(MB_OKCANCEL | MB_ICONQUESTION);
  89.    if (MessageBox(hWnd, (LPSTR)szOkClose, (LPSTR)szClose,
  90.        MB_OKCANCEL | MB_ICONQUESTION) == IDOK) {
  91.        DestroyWindow(hWnd);
  92.        CloseComm(nCID);
  93.        }
  94. }
  95.  
  96. TermEndSession(hWnd, bEnding)
  97. HWND hWnd;
  98. BOOL bEnding;
  99. {
  100.    if (bEnding) {                         /* really ending */
  101.        if ( Capture == TRUE )
  102.            CloseCapture();
  103.        if ( nCID )
  104.            CloseComm(nCID);
  105.        nCID = NULL;
  106.        LocalUnlock( hCommHandle );    /* Unlock and free the DCB Buffer */
  107.        LocalFree( hCommHandle );
  108.        DestroyCaret();
  109.        RemoveFontResource( (LPSTR) "FONTRES.FON" ); /* Remove the Fonts */
  110.        RemoveFontResource( (LPSTR) "IBM.FON" );
  111.        DeleteObject( IBMfont );
  112.        SelectObject(hTermDC,GetStockObject(SYSTEM_FONT));/* Get system font */
  113.        ReleaseDC(hWndTerm,hTermDC);
  114.        }
  115.    else
  116.        {
  117.        /* someone replied FALSE to WM_QUERYENDSESSION */
  118.        }
  119. }
  120.  
  121. TermEraseBkgnd(hWnd, hDC)    /* Disabled in termres.c */
  122. HWND hWnd;
  123. HDC  hDC;
  124. {
  125.     HBRUSH  hbr, hbrOld;
  126.     RECT    rect;
  127.  
  128.     GetClientRect(hWnd, (LPRECT)&rect);
  129.     hbrOld = SelectObject( hDC, hbrWhite );
  130.     FillRect(hDC, (LPRECT)&rect, hbr);
  131.     SelectObject(hDC, hbrOld);
  132. }
  133.  
  134. TermKeyInput(hWnd, message, ch)
  135. HWND hWnd;
  136. unsigned message;
  137. int ch;
  138. {
  139.     switch (message) {
  140.         case WM_KEYDOWN:
  141.            TranslateKey( ch );
  142.            break;
  143.         case WM_KEYUP:
  144.            break;
  145.     }
  146. }
  147.  
  148. TermGetFocus(hWnd, hWndPrevFocus)
  149. HWND hWnd;
  150. HWND hWndPrevFocus;
  151. {
  152. DestroyCaret();
  153. CreateCaret( hWndTerm, NULL, char_w, char_h );
  154. SetCaretPos( curs_pos.x, curs_pos.y );
  155. TermHasFocus = TRUE;
  156. TermShowCaret( TRUE );
  157. }
  158.  
  159. TermLoseFocus(hWnd, hWndNewFocus)
  160. HWND hWnd;
  161. HWND hWndNewFocus;
  162. {
  163. DestroyCaret();
  164. TermHasFocus = FALSE;
  165. }
  166.  
  167. TermMouse(hWnd, message, wParam, lParam)
  168. HWND       hWnd;
  169. unsigned   message;
  170. WORD       wParam;
  171. POINT      lParam;
  172. {
  173. }
  174.  
  175. TermMove(hWnd, x, y)
  176. HWND hWnd;
  177. int x, y;
  178. {
  179. int i;                      /* Save the cords. of the window */
  180. GetWindowRect(hWnd,(LPRECT)&rect);
  181. if ((rect.right-rect.left > GetSystemMetrics(SM_CXICON)+10) ||
  182.         (rect.bottom-rect.top > GetSystemMetrics(SM_CYICON)+10)) {
  183.    CopyRect((LPRECT)&win_sz.size,(LPRECT)&rect);
  184.    }
  185. return( TRUE );
  186. }
  187.  
  188. TermPaint( hWnd )
  189. HWND  hWnd;
  190. {
  191. int   i,j;
  192. HDC   hDC;
  193. HFONT htmp;
  194.  
  195. hDC = BeginPaint (hWnd, (LPPAINTSTRUCT) &ps);
  196. if ( PaintWindow ) {  /* Window is not painted after a scroll, saves time */
  197.     /****************************************
  198.     * if window is not open, don't paint    *
  199.     ****************************************/
  200.     if ((no_lines == 0) || (win_size == SIZEICONIC)) {
  201.         EndPaint (hWnd, (LPPAINTSTRUCT) &ps);
  202.         return(0L);
  203.         }
  204.     /*********************************
  205.     * paint window                   *
  206.     *********************************/
  207.     htmp = SelectObject( hDC, IBMfont );
  208.     i = ps.rcPaint.top / char_h;
  209.     for(;i<no_lines;i++) {
  210.         for ( j = no_cols-1; j > 0 && *(display[i].string+j) == ' '; j-- );
  211.         TextOut(hDC,char_w,((char_h*i)?(char_h*i):1),(LPSTR)display[i].string,++j);
  212.         }
  213.    }                                /* End if ( PaintWindow ) */
  214. PaintWindow = TRUE;
  215. EndPaint(hWnd,(LPPAINTSTRUCT) &ps);
  216. }
  217.  
  218. TermQueryEndSession(hWnd)
  219. HWND hWnd;
  220. {
  221.     int id;
  222.     char    szOkSave[CCHMAXSTRING], szSave[CCHMAXSTRING];
  223.  
  224. #if 0          /* Disabled */
  225.     LoadString(hInstTerm, IDSOKSAVE, (LPSTR)szOkSave, CCHMAXSTRING);
  226.     LoadString(hInstTerm, IDSSAVE  , (LPSTR)szSave  , CCHMAXSTRING);
  227.     MessageBeep(MB_OKCANCEL | MB_ICONQUESTION);
  228.     id = MessageBox(hWnd, (LPSTR)szOkSave, (LPSTR)szSave,
  229.         MB_YESNOCANCEL | MB_ICONQUESTION);
  230.     switch (id)
  231.     {
  232.         case IDYES:
  233.             /* save files etc and fall through */
  234.         case IDNO:
  235.             /* don't save but still permit End Eession to continue */
  236.             return TRUE;
  237.         case IDCANCEL:
  238.             /* don't allow End Session to continue */
  239.             return FALSE;
  240.     }
  241. #endif
  242. }
  243.  
  244. TermSize(hWnd, x, y, code, lParam)
  245. HWND hWnd;
  246. int  x, y;
  247. int  code;
  248. long lParam;
  249. {
  250. int  h, w;
  251. long lng;
  252. TEXTMETRIC tm;
  253.  
  254. win_sz.icon = FALSE;
  255. DestroyCaret();
  256. switch (code) {
  257.    case SIZEICONIC:
  258.        if (win_size != SIZEICONIC) {
  259.            /****************************************
  260.            * reset variables to reflect status     *
  261.            ****************************************/
  262.            win_size = SIZEICONIC;
  263.            win_sz.icon = TRUE;
  264.            /****************************************
  265.            * set the timer to monitor the serial   *
  266.            *  port while program is iconic         *
  267.            ****************************************/
  268.            KillTimer(hWndTerm,OPEN_TIMER);
  269.            SetTimer(hWndTerm,ICON_TIMER,ICON_RATE, lpprocTimer);
  270.            }
  271.        break;
  272.    case SIZEFULLSCREEN:
  273.        win_size = SIZENORMAL;
  274.        *buff = 0x11; /* CONTROL Q: Start Transmission again, just for kicks */
  275.        ret = WriteComm( nCID, (LPSTR) buff, 1 );
  276.        if ( flashing ) {
  277.            flashing = FALSE;
  278.            KillTimer(hWndTerm,FLASH_TIMER);
  279.            SetTimer(hWndTerm,OPEN_TIMER,OPEN_RATE,NULL);
  280.            }
  281.        break;
  282.    case SIZENORMAL:
  283.        win_size = SIZENORMAL;
  284.        if ( no_cols  < 1 || no_cols  > MAX_COLS  ) no_cols  = 80; /* Check  */
  285.        if ( no_lines < 1 || no_lines > MAX_LINES ) no_lines = 24; /* Bounds */
  286.        w = LOWORD(lParam) / no_cols;    /* Determine best fit cursor values */
  287.        h = HIWORD(lParam) / no_lines;
  288.  
  289.        w = (w <  1 ?  1 : w );          /* Check bounds */
  290.        w = (w > 20 ? 20 : w );
  291.        h = (h <  1 ?  1 : h );
  292.        h = (h > 20 ? 20 : h );
  293.  
  294.        if ( IBMfont )                 /* remove current font  */
  295.            DeleteObject( IBMfont );
  296.                                       /* Create best fit font */
  297.        IBMfont = CreateFont( h, w,0,0,0,0,0,0,
  298.                    OEM_CHARSET, OUT_DEFAULT_PRECIS,
  299.                    CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
  300.                    FIXED_PITCH|FF_DONTCARE, (LPSTR) "IBM" );
  301.        if ( IBMfont == NULL ) {       /* Unable to load font    */
  302.            pmsg("Unable to select font.");
  303.            IBMfont = GetStockObject( SYSTEM_FONT );
  304.            }
  305.        SelectObject( hTermDC, IBMfont ); /* Select font */
  306.  
  307.        /* Get new fonts values. NOTE: Font created may NOT match the    */
  308.        /* values asked for.  Windows gives the closest match.           */
  309.        GetTextMetrics (hTermDC, (TEXTMETRIC FAR *)&tm); /* text size    */
  310.        char_w = tm.tmAveCharWidth;                      /* char width   */
  311.        char_h = tm.tmHeight + tm.tmExternalLeading;     /* char height  */
  312.  
  313.        w = char_w * (no_cols  + 6); /* Size window acording to new font */
  314.        h = char_h * (no_lines + 6);
  315.        GetWindowRect(hWnd,(LPRECT)&rect);
  316.        MoveWindow( hWndTerm, rect.left, rect.top, w, h, TRUE);
  317.        if ((rect.right-rect.left > GetSystemMetrics(SM_CXICON)+10) ||
  318.                (rect.bottom-rect.top > GetSystemMetrics(SM_CYICON)+10)) {
  319.           CopyRect((LPRECT)&win_sz.size,(LPRECT)&rect);
  320.           }
  321.  
  322.        if ( flashing ) {
  323.            flashing = FALSE;
  324.            KillTimer(hWndTerm,FLASH_TIMER);
  325.            SetTimer(hWndTerm,OPEN_TIMER,OPEN_RATE,NULL);
  326.            }
  327.        break;
  328.    }
  329.  
  330. PaintWindow = TRUE;
  331. GetWindowRect(hWnd, (LPRECT)&win_sz.size);     /* get screen size */
  332. CreateCaret( hWndTerm, NULL, char_w, char_h );
  333. curs_pos.x = char_w * (next_char+1);
  334. curs_pos.y = char_h * next_line;
  335. TermShowCaret( TRUE );
  336. return( TRUE );
  337. }
  338.  
  339.  
  340. long TermCommand(hWnd, message, wParam, lParam)
  341. HWND       hWnd;
  342. unsigned   message;
  343. WORD       wParam;
  344. LONG       lParam;
  345. {
  346. int i;
  347. HMENU commands;
  348.     switch (wParam) {
  349.        case IDMFILE:         /* Select Configuration file, open comm port */
  350.            ret = DialogBox(hInstTerm,MAKEINTRESOURCE(PATHBOX),hWndTerm,lpprocSelectDlg);
  351.            if ( ret && ReadConfig() == FALSE )/* Read the termcap - .cnf file */
  352.                return(FALSE);
  353.  
  354.            if ( TermOpenComm( ) == FALSE )   /* Open the comm port           */
  355.                return(FALSE);
  356.            *buff = CR;
  357.            WriteComm( nCID, (LPSTR) buff, 1 ); /* Jump start the port */
  358.            EnableMenuItem( hMenuMain, 1, MF_BYPOSITION|MF_ENABLED );
  359.            /****************************************
  360.            * Put a message in the queue            *
  361.            *  to go and look for a response        *
  362.            ****************************************/
  363.            PostMessage(hWndTerm,WM_TIMER,OPEN_TIMER,(LONG)NULL);
  364.  
  365.            /****************************************
  366.            * Set the timer to monitor the serial   *
  367.            *  port                                 *
  368.            ****************************************/
  369.            ret = SetTimer(hWndTerm,OPEN_TIMER,OPEN_RATE,NULL);
  370.            if (!ret) {                       /* error starting timer             */
  371.                pmsg("Error starting open timer");
  372.                PostMessage(hWndTerm,WM_CLOSE,NULL,(LONG)NULL);/* post closing msg */
  373.                }
  374.            break;
  375.        case IDMCONNECT:      /* Connect to comm port - disabled */
  376.            break;
  377.        case IDMDIALOG:    /* Show the message dialog window  */
  378.            ShowWindow(hWdesc, SW_NORMAL);
  379.            break;
  380.        case IDMCONFIG:    /* Show the configuration window   */
  381.            DialogBox(hInstTerm,MAKEINTRESOURCE(CONFIGTERM),hWnd,lpprocConfigTerm);
  382.            break;
  383.        case IDMCLEAR:     /* Clear the display               */
  384.            TermShowCaret( FALSE );
  385.            next_char  = 0;
  386.            next_line  = 0;
  387.            curs_pos.x = char_w;
  388.            curs_pos.y = 1;
  389.            GraphicsMode = FALSE;
  390.            SetCaretPos( curs_pos.x, curs_pos.y );
  391.            for ( i = 0; i < no_lines; i++ )
  392.                memset( display[i].string, ' ', no_cols );
  393.            GetClientRect( hWndTerm, (LPRECT) &rect );
  394.            FillRect( hTermDC, (LPRECT) &rect, GetStockObject(WHITE_BRUSH));
  395.            TermShowCaret( TRUE );
  396.            break;
  397.        case IDMON:        /* Turn capture mode on */
  398.            commands = GetSubMenu( hMenuMain, 2 );
  399.            if ( Capture == FALSE )
  400.                OpenCapture();
  401.            CheckMenuItem( commands, IDMON,   MF_CHECKED   );
  402.            CheckMenuItem( commands, IDMOFF,  MF_UNCHECKED );
  403.            Capture = TRUE;
  404.            break;
  405.        case IDMOFF:       /* Turn capture mode off */
  406.            if ( Capture == TRUE )
  407.                CloseCapture();
  408.            commands = GetSubMenu( hMenuMain, 2 );
  409.            CheckMenuItem( commands, IDMON,   MF_UNCHECKED );
  410.            CheckMenuItem( commands, IDMOFF,  MF_CHECKED   );
  411.            Capture = FALSE;
  412.            break;
  413.        default:
  414.            return(DefWindowProc(hWnd, message, wParam, lParam));
  415.            break;
  416.        }
  417. return( 0L );
  418. }
  419.  
  420.  
  421. long TermSysCommand(hWnd, message, wParam, lParam)
  422. HWND       hWnd;
  423. unsigned   message;
  424. WORD       wParam;
  425. LONG       lParam;
  426. {
  427.     switch (wParam) {
  428.         case IDMABOUT:
  429.            DialogBox(hInstTerm, MAKEINTRESOURCE(ABOUTDIALOG), hWnd,
  430.                 lpprocTermAboutDlg);
  431.            return TRUE;
  432.            break;
  433.  
  434.        case IDMSAVEWINDOW:      /* Save the window size */
  435.            LoadString( hInstTerm, IDSWINDOWNAME, (PSTR) win_sz.app_name, 30 );
  436.            ret = SaveWindowSize(&win_sz);
  437.            if (ret)
  438.                MessageBox(hWndTerm,(LPSTR)"Error saving coordinates",NULL,MB_OK);
  439.            return TRUE;
  440.            break;
  441.  
  442.         /* N.B MUST HAVE A CALL TO DefWindowProc HERE !!!!! */
  443.         default:
  444.            return(DefWindowProc(hWnd, message, wParam, lParam));
  445.            break;
  446.         }
  447.     return (0L);
  448. }
  449.  
  450.  
  451. TermTimer( hWnd, TimerID )
  452. HWND   hWnd;
  453. WORD   TimerID;
  454. {
  455. int      size_read;
  456. unsigned int u;
  457. char     port_char;
  458. COMSTAT  CommStatus;
  459.  
  460. if (TimerID == OPEN_TIMER) {
  461.     if (win_size == SIZENORMAL) {   /* make sure window is open            */
  462.        u = GetCommError( nCID, (COMSTAT *) &CommStatus );
  463.        if ( CommStatus.cbInQue )    /* A Character is in the receive queue */
  464.            ReadLine( );             /* Read from the port                  */
  465.        }                            /* End if(win_size == SIZENORMAL)      */
  466.     else
  467.         KillTimer(hWndTerm,OPEN_TIMER);
  468.     }                               /* End if(wParam == OPEN_TIMER)        */
  469. /*****************************************
  470. * process the timer that is set to flash *
  471. *   the icon, it is set when data is     *
  472. *   waiting to be displayed and the      *
  473. *   program is iconic                    *
  474. *****************************************/
  475. else if ((TimerID == FLASH_TIMER) && (flashing)) {
  476.    if (win_size == SIZEICONIC) {
  477.        if (message_action == MSG_FLASH) {
  478.            GetWindowRect(hWndTerm,(LPRECT)&rect);
  479.            FlashWindow(hWndTerm,TRUE);
  480.            }
  481.        else if (message_action == MSG_BEEP) {
  482.            Beep();
  483.            GetWindowRect(hWndTerm,(LPRECT)&rect);
  484.            FlashWindow(hWndTerm,TRUE);
  485.            }
  486.        else if (message_action == MSG_OPEN) {
  487.            KillTimer(hWndTerm,FLASH_TIMER);
  488.            SetTimer(hWndTerm,OPEN_TIMER,OPEN_RATE,NULL);
  489.            ShowWindow( hWndTerm, SW_RESTORE );
  490.            }
  491.        else if (message_action == MSG_DISP) {
  492.            KillTimer(hWndTerm,FLASH_TIMER);
  493.            MessageBox(hWndTerm,
  494.            (LPSTR)"    THERE IS A MESSAGE FROM THE ICU - PLEASE OPEN TERMINAL ICON    ",
  495.            (LPSTR)" ATTENTION!!! ",MB_ICONHAND|MB_OK);
  496.            SetTimer(hWndTerm,FLASH_TIMER,FLASH_RATE * 3,NULL);
  497.            }
  498.        }
  499.    else {
  500.        KillTimer(hWndTerm,FLASH_TIMER);
  501.        flashing = FALSE;
  502.        }
  503.    }
  504. }
  505.  
  506. /* */
  507. /*doc************************************************************************
  508. *
  509. *     NAME
  510. *
  511. *     Timer() - processes the timer interrupt
  512. *
  513. *     FORMAT
  514. *
  515. *     BOOL FAR PASCAL Timer(hWnd, message, wParam, lParam)
  516. *     HWND hWnd;
  517. *     unsigned  message;
  518. *     WORD  wParam;
  519. *     LONG  lParam;
  520. *
  521. *     DESCRIPTION
  522. *     When the timer interrupts, this function is called. The timer is
  523. *     only set when the program is iconic. When it goes off, this function
  524. *     goes out and reads the serial port to see if there is any message
  525. *     waiting from the unix box. If there is, the entire line that is
  526. *     waiting is read (if no errors), and the action determined by the
  527. *     message variable is taken. The possible values for this are
  528. *         FLASH - this means to flash the icon
  529. *         BEEP - flash the icon and sound the beeper
  530. *         OPEN - open a message box informing the user
  531. *
  532. *     This timer that polls the port is killed since it is no longer
  533. *     necessary once data has been found. If an error is found while
  534. *     reading, a message box is brought up to that effect, but the
  535. *     program continues on after the error is acknowledged.
  536. *
  537. *     RETURN VALUE
  538. *
  539. *     MODIFIES
  540. *     flashing
  541. *
  542. *     REFERENCES
  543. *     ReadComm()
  544. *     DisplayCommError()
  545. *     ReadLine()
  546. *
  547. *end************************************************************************/
  548. BOOL FAR PASCAL Timer(hWnd, message, wParam, lParam)
  549. HWND      hWnd;
  550. unsigned  message;
  551. WORD      wParam;
  552. LONG      lParam;
  553. {
  554. /****************************************
  555. * local variable declarations           *
  556. ****************************************/
  557. int  ret;
  558. unsigned int u;
  559. COMSTAT CommStatus;
  560. /****************************************
  561. * see if anything at port               *
  562. ****************************************/
  563. u = GetCommError( nCID, (COMSTAT *) &CommStatus );
  564. if ( CommStatus.cbInQue ) {
  565.    return( FALSE );      /* no bytes were read from port     */
  566.    }                     /* keep going                       */
  567.  
  568. /****************************************
  569. * if the return was not zero than there *
  570. *  is something at the port - if so,    *
  571. *  read till the end of the line and    *
  572. *  notify the user that there is some   *
  573. ****************************************/
  574. KillTimer(hWndTerm,ICON_TIMER);   /* kill poll timer since data found */
  575. ret = ReadLine( );
  576. if (ret)
  577.    DisplayCommError();
  578.  
  579. if (!flashing) {
  580.    SetTimer(hWndTerm,FLASH_TIMER,FLASH_RATE,NULL);
  581.    flashing = TRUE;
  582.    return(TRUE);
  583.    }
  584. return(FALSE);
  585. }
  586.  
  587.